﻿using System;
using Windows.Globalization.DateTimeFormatting;
using Windows.UI.Xaml.Data;

namespace Looptribe.Moodlin8.UIHelper
{
    public class MonthTitleConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string culture)
        {
            var month = value as int?;
            return month != null ? GetMonthTitle((int)month) : value.ToString();
        }

        public object ConvertBack(object value, Type targetType, object parameter,
                                  string culture)
        {
            throw new NotSupportedException();
        }

        private static string GetMonthTitle(int month)
        {
            var mon = new DateTime(2013, month, 1);
            var dateFormatter = new DateTimeFormatter("{month.full}");
            return dateFormatter.Format(mon) + " 2013";
        }
    }
}
